const messageService = require('../services/message');
const messageCode = require('../codes/message');

module.exports = {

	/**
	 * [getMessage 获取用户所有消息]
	 * @param  {[type]} userId      [用户id]
	 * @return {[type]}             [description]
	 */
	async getAllMessage(ctx) {
		let formData = ctx.request.body;
		let result = {
			success: false,
			message: '消息获取失败',
			data: null,
			code: ''
		};

		let messageResult = await messageService.getAllMessage({
			to_user: formData.userId,
		});
		if(messageResult) {
			result.success = true;
			result.data = messageResult;
			result.message = '消息获取成功';
		}
		ctx.body = result;
	},

};